package com.tbit.main.util.fuse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 熔断器配置类
 *
 * @Author:BUGTian
 * @DATE: 2021/10/26
 */
@Configuration
public class FuseConfig {

    /**
     * 最大调用失败次数
     */
    @Value("${fuse.failureThreshold}")
    private int failureThreshold;

    /**
     * 连续调用成功次数
     */
    @Value("${fuse.consecutiveSuccessThreshold}")
    private int consecutiveSuccessThreshold;

    /**
     * 超时时间(单位:毫秒)
     */
    @Value("${fuse.timeout}")
    private int timeout;

    @Bean
    public BreakerManager breakerManager() {
        return new BreakerManager(failureThreshold, consecutiveSuccessThreshold, timeout);
    }
}
